package main;

import action.HoverColor;
import java.awt.Point;
import org.netbeans.api.visual.action.ActionFactory;
import org.netbeans.api.visual.action.PopupMenuProvider;
import org.netbeans.api.visual.action.WidgetAction;
import org.netbeans.api.visual.widget.LabelWidget;
import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Scene;
import popup.PopupProviderEntidade;

/**
 * @author Slompo
 */
public class TestLabelInBoxMove {

    public static void main(String[] args) {
        Scene scene = new Scene();

        LayerWidget layerWidget = new LayerWidget(scene);
        scene.addChild(layerWidget);

        LabelWidget labelWidget = createLabel(scene, "Slompo", 100, 100);
        layerWidget.addChild(labelWidget);

        scene.getActions().addAction(ActionFactory.createZoomAction());
        scene.getActions().addAction(ActionFactory.createPanAction());

        labelWidget.getActions().addAction(ActionFactory.createMoveAction());
        
        WidgetAction hoverAction = ActionFactory.createHoverAction (
                new HoverColor());
        scene.getActions().addAction(hoverAction);
        labelWidget.getActions().addAction(hoverAction);
        
        WidgetAction popupEntidade = ActionFactory.createPopupMenuAction(
                new PopupProviderEntidade());
        labelWidget.getActions().addAction(popupEntidade);

        SceneSupport.show(scene.createView());
    }
    
    private static LabelWidget createLabel(Scene scene, String text, int x, int y) {
        LabelWidget widget = new LabelWidget(scene, text);
        widget.setFont(scene.getDefaultFont().deriveFont(24.0f));
        widget.setOpaque(true);
        widget.setPreferredLocation(new Point(x, y));
        return widget;
    }
}
